// ajax操作
// 引入ajax
// 引入代理路径
import axios, { url } from '.';

// 查
export const findType = async (data) => {
    let res = await axios({
        method: 'get',
        url: url + '/types/',
        params: data
    })
    return res.data;

}
export const findAll = async (data) => {
    let res = await axios({
        method: 'get',
        url: url + '/types/all',
        params: data
    })
    return res.data;
}

// 增加类型
// 增加
export const addTypes = async (data) => {
    console.log("是否进入");
    let res = await axios({
        method: 'post',
        url: url + '/types/',
        data
    })
    console.log("但是犯得上士大夫");
    console.log("增加11111111：", data);
    return res.data
}
// 删除
export const deleteId = async (id) => {
    let res = await axios({
        method: 'delete',
        url: url + '/types/' + id,
    })
    console.log("进入删除");
    return res.data
}


// 通过id得数据
export const getById = async (id) => {
    let res = await axios({
        method: 'get',
        url: url + '/types/' + id,
    })
    return res.data;
}

// 修改
export const updateType = async (data) => {
    let res = await axios({
        method: 'put',
        url: url + '/types/' + data._id,
        data
    })
    console.log("前端修改");
    return res.data;

}